Dough Git

clove/pkviewer

web/src/routes/manage/[systemId]/address/+page.server.ts

back to web/src/routes/manage/[systemId]/address

/* web/src/routes/manage/[systemId]/address/+page.server.ts */
import { error } from "@sveltejs/kit";
import type { PageServerLoad } from "./$types";
import { manageApi, seg } from "$lib/server/api.ts";
import type { SlugStatus } from "$lib/types.ts";

// The address is a product feature: this is where a manager sees and changes the shared URL
export const load: PageServerLoad = async ({ params, parent }) => {
  const { system } = await parent();
  const status = await manageApi.get<SlugStatus>(
    `/manage/slugs/status?scope=system&subjectId=${seg(params.systemId)}`,
  );
  if (!system || !status.ok) error(404);
  return {
    system,
    status: status.value,
  };
};